﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _1025HomeWork
{
    public abstract class Animal : IMoveable
    {
        public string aName;
        public int X;
        public int Y;
        //抽象函数，本例使用抽象函数实现多态
        public abstract string Say();
        public abstract string SayHello(string fName);

        public void Move(SquareClass _square)
        {
            int dx = _square.rnd.Next(-1, 2);//产生的随机数不包括上界值
            int dy = _square.rnd.Next(-1, 2);
            if (X + dx < _square.Width && X + dx >= 0) X = X + dx;
            if (Y + dy < _square.height && Y + dy >= 0) Y = Y + dy;
        }
    }
}
